package cn.admin.remoting;

import java.util.Map;

public interface Server extends ConnectionFactory {

    int getPort();

    String getBindIp();

    void start() throws RemotingException;

    void stop() throws RemotingException;

    boolean isStarted();

    void sendToGroups(Map<String, Object> groupDatas,
                      ResponseCallback.GroupRandomResponseCallback callback,
                      long timeout, Object... callbackArgs) throws RemotingException;

    void sendToGroupOneway(String group, Object payloadObject) throws RemotingException;

    ResponseFuture invokeWithFuture(Object appRequest, Connection connection, long waitTimeoutMs, byte protocol)
            throws RemotingException;

    void sendToGroupAllOneway(String group, Object payload, byte protocol);

    void sendToGroupAllCallback(String group, Object payload,
                                ResponseCallback.MultiResponseCallback totalCallback, byte protocol, long waitTimeoutMs);

    void setGroupConnectionStrategy(GroupConnectionStrategy strategy);

    interface GroupConnectionStrategy {

        Connection getConnection(String groupName);

    }

}
